const mongoose = require("mongoose");
mongoose.pluralize(null); //去掉集合后面的s
const { Schema, model } = mongoose;
const versionKey = { versionKey: false };
const moment = require("moment");
moment.locale("zh-cn");

// 收藏表
const CollectionSchema = new Schema({
    user_uid: String,//收藏用户uid
    author_uid: String,//作者uid
    user_id: {//关联用户表
        type: mongoose.Types.ObjectId,
        ref: 'user',
        required: true
    },
    article_id: {//关联游记表
        type: mongoose.Types.ObjectId,
        ref: 'usertravel',
        required: true
    },
    time: {
        type: String,
        default: () => moment().utcOffset(8).format('YYYY-MM-DD')
    }
}, versionKey)

module.exports = {
    modelCollection: model('collection', CollectionSchema)
}